package com.itelite.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itelite.domain.dto.RecordParam;
import com.itelite.domain.dto.TeacherParam;
import com.itelite.domain.dto.TeacherRecordExcel;
import com.itelite.domain.pojo.Teacher;
import com.itelite.mapper.TeacherMapper;
import com.itelite.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 沈洋 邮箱:1845973183@qq.com
 * @create 2021/8/8-18:15
 **/
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;
    @Override
    public List<Teacher> getTeachers() {
        return teacherMapper.queryTeachers(new TeacherParam());
    }

    @Override
    public PageInfo<Teacher> getTeachers(TeacherParam param) {
        PageHelper.startPage(param.getPageNum(), param.getPageSize());
        List<Teacher> teachers = teacherMapper.queryTeachers(param);
        return new PageInfo<>(teachers);
    }

    @Override
    public boolean addTeacher(Teacher teacher) {
        return teacherMapper.insertTeacher(teacher)>0;
    }

    @Override
    public boolean deleteTeacher(Integer teacherId) {
        return teacherMapper.updateTeacherState(teacherId,-1)>0;
    }


}
